﻿<%@ page title="" language="C#" masterpagefile="~/Training.master" autoeventwireup="true" inherits="Training.Web.Lists.Administration.Catalog.InqueryPesertaList, App_Web_tml0wt00" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveUrl("~/styles/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/i18n/grid.locale-id.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/jquery.jqGrid.min.js") %>"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.msgBox.v1.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/chosen/chosen.jquery.min.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />
    <div>
        <table border="0">
            <tr>
                <td>
                    NIK
                </td>
                <td>
                    :
                </td>
                <td>
                    <table border="0">
                        <tr>
                            <td>
                                <asp:DropDownList ID="ddlNIK" runat="server" Width="300">
                                </asp:DropDownList>
                            </td>
                            <td style="padding-left:50px;">
                                Bagian
                            </td>
                            <td style="padding-left:10px;">
                                :
                            </td>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtBagian" runat="server" Width="500"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    Nama Peserta
                </td>
                <td>
                    :
                </td>
                <td>
                   

                    <table border="0">
                        <tr>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtNamaPeserta" runat="server" Width="300"></asp:TextBox>
                            </td>
                            <td style="padding-left:45px;">
                                Jabatan
                            </td>
                            <td style="padding-left:5px;">
                                :
                            </td>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtJabatan" runat="server" Width="500"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    Departemen
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:TextBox ReadOnly="true" ID="txtDepartemen" runat="server" Width="300"></asp:TextBox>
                </td>
            </tr>
           
            <tr runat="server" visible="false">
                <td colspan="3">
                    <div style="text-align: right; padding-top: 10px;">
                        <button id="btnProcess" type="button">
                            Proses</button>
                    </div>
                </td>
            </tr>
        </table>
    </div>
     <br />
    <div style="overflow: auto; height: 350px;">
        <table id="table" class="scroll" cellpadding="0" cellspacing="0">
        </table>
        <div id="pager" class="scroll">
        </div>
        <br />
        <div id="dialog" title="Default dialog">
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%= ddlNIK.ClientID %>').chosen({ placeholder_text_single: "-- pilih NIK --" });

            $('#<%= ddlNIK.ClientID %>').change(function () {

                $('#<%= txtNamaPeserta.ClientID %>').val('');
                $('#<%= txtBagian.ClientID %>').val('');
                $('#<%= txtDepartemen.ClientID %>').val('');
                $('#<%= txtJabatan.ClientID %>').val('');
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/PesertaLoadHandler.ashx") %>';
                var pesertaID = $("#<%= ddlNIK.ClientID %> option:selected").val();
                
                if (pesertaID != "") {
                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + "?method=getbyid&pesertaID=" + pesertaID,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $('#<%= txtNamaPeserta.ClientID %>').val(datas.NamaPeserta);
                            $('#<%= txtBagian.ClientID %>').val(datas.Departemen);
                            $('#<%= txtDepartemen.ClientID %>').val(datas.Bagian);
                            $('#<%= txtJabatan.ClientID %>').val(datas.Jabatan);
                        },
                        error: function () {
                            $.msgBox("Error load peserta  !", null, { title: "Pesan Error" });
                        }
                    });

                    //END
                }

                var pesertaID = $('#<%= ddlNIK.ClientID  %> option:selected').val();
                if (pesertaID == "")
                    pesertaID = 0;

                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';
                $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypeserta&pesertaID=' + pesertaID });
                $("#table").trigger("reloadGrid");

            });

        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").click(function () {
            var pesertaID = $('#<%= ddlNIK.ClientID  %> option:selected').val();
            if (pesertaID == "")
                pesertaID = 0;

            var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';
            $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypeserta&pesertaID=' + pesertaID });
            $("#table").trigger("reloadGrid");
        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").button({ icons: { primary: "ui-icon-search"} });
    </script>

     <script type="text/javascript">

         var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';

         var pesertaID = $('#<%= ddlNIK.ClientID  %> option:selected').val();
         if (pesertaID == "")
             pesertaID = 0;

         $('#table').jqGrid({
             url: handlerUrl + '?method=getdatabypeserta&pesertaID=' + pesertaID,
             datatype: 'json',
             colNames: ['ID', 'Nama Pelatihan', 'Tgl. Mulai','Tgl. Akhir', 'Tempat Pelatihan', 'Pembicara'],
             colModel: [
                { name: 'PelatihanID', key: true, hidden: true, index: 'PelatihanID', width: 60 },
                { name: 'NamaPelatihan', index: 'NamaPelatihan', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'TglPelatihan', index: 'TglPelatihan', align: 'center', width: 150, search: false, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
                { name: 'TglAkhirPelatihan', index: 'TglAkhirPelatihan', align: 'center', width: 150, search: false, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
                { name: 'TempatPelatihan', index: 'TempatPelatihan', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'Pembicara.NamaPembicara', index: 'NamaPembicara', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} }
           	],
             rownumbers: true,
             rowNum: 10,
             id: 'PelatihanID',
             multiselect: false,
             rowList: [5, 10, 15, 20],
             pager: '#pager',
             sortname: 'NamaPelatihan',
             sortorder: "asc",
             viewrecords: true,
             jsonReader: { repeatitems: false },
             width: 1000,
             height: '100%',
             caption: 'Pelatihan',
             ajaxGridOptions: { cache: false }
         });

         $("#table").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, searchtext: 'Search', refreshtext: 'Refresh' },
        {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });

       
    
    </script>
</asp:Content>
